﻿using System.ComponentModel;

namespace Client.BlazorWasmApp.Models;

public class MenuModel : INotifyPropertyChanged
{
    //private readonly Func<IList<MenuModel>?> _collection;
    //public MenuModel(Func<IList<MenuModel>> collection)
    //{
    //    this._collection = collection;
    //}

    //bool _expanded;
    //public bool Expanded
    //{
    //    get
    //    {
    //        return _expanded;
    //    }
    //    set
    //    {
    //        if (_expanded != value)
    //        {
    //            _collection()?.Where(i => i != this).ToList().ForEach(s => s.Expanded = false);

    //            _expanded = value;
    //            OnPropertyChanged(nameof(Expanded));
    //        }
    //    }
    //}

    public IList<MenuModel>? Children { get; set; }

    public string? Text { get; set; }

    public string Url { get; set; }

    public string Icon { get; set; }

    public event PropertyChangedEventHandler? PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}